package sctu.edu.java.year2016.team03.maoyuhao.day20160522.chapter6_2;

/**
 * 不用前面介绍的两种方法， 只用if和for循环实现对空格的去除
 * Created by cc on 2016/5/22.
 */
public class Work {
    public static void main(String[] args) {
        String s="  as a  ah fh a f  ja df";
        for (int i = 0; i < s.length(); i++) {
            if (s.charAt(i) == ' ') {
                s = s.replace(" ", "");
            }
        }
        System.out.println(s);
    }

}